ARG BASE_IMAGE_TAG

FROM $BASE_IMAGE_TAG
ARG TGT_DIR
ARG DEPS
RUN yum -y install $DEPS
COPY delta.gitconfig vimrc common.sh install.sh clean.sh init.sh /tmp/root/$TGT_DIR/
COPY pkgs /tmp/root/$TGT_DIR/pkgs
RUN set -eux; \
	export TARGET=/tmp/root/usr/local; \
	mkdir -p $TARGET/bin; \
	export PATH=$TARGET/bin:$PATH; \
	export BASH_COMPLETION_D=/tmp/root/etc/bash_completion.d; \
	mkdir -p $BASH_COMPLETION_D; \
	cd /tmp/root/$TGT_DIR; \
	./install.sh; \
	./clean.sh

FROM $BASE_IMAGE_TAG
ENV TERM=xterm-256color
ARG TGT_DIR
ARG DEPS
COPY --from=0 /tmp/root /
RUN set -eux; yum -y install $DEPS; \
	yum clean all; rm -rf /var/cache/yum; \
	cd $TGT_DIR; ./init.sh
CMD ["bash"]
